<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Http\Traits\BroadcastHttpPush;

class HomeController extends Controller
{
    use BroadcastHttpPush;
    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
       $this->middleware('auth')->except('test');
    }

    /**
     * Show the application dashboard.
     *
     * @return \Illuminate\Contracts\Support\Renderable
     */
    public function index()
    {

        return view('home');
    }
    
    public function test() {
        
        $broadcastChannel = array(

            "channel" => "private-team.1",   // 通道名，`private-`表示私有

            "name" => "App\\Events\\NewWarn",    // 事件名

            "data" => array(

                "warns" => [
                    
                    "warnNew" => [

                    ], 
                    "warnTotal" => 30
                ]

            )

        );

        $this->push($broadcastChannel);
    }
}
